package org.zfes.snowier.cloud.zbss.cms.router.service.tag;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.tag.model.CmsTag;
import org.zfes.snowier.cloud.zbss.cms.tag.service.ICmsTagService;
@Controller 
@RequestMapping("/cms/tag/cmsTag")
public class CmsTagController extends BaseController {

	
	@Autowired
	private ICmsTagService cmsTagService;
	
	@RequiresPermissions(value="cmsTag:loadCmsTagDataSet",desc="标签列表")
    @RequestMapping(value="/loadCmsTagDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTagDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsTagService.loadCmsTagDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsTag:createCmsTag",desc="标签添加")
    @RequestMapping(value="/createCmsTag", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsTag(CmsTag cmsTag){
		cmsTagService.createCmsTag(cmsTag);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTag:loadCmsTag",desc="标签加载")
    @RequestMapping(value="/loadCmsTag", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTag(Long id){
		Optional<CmsTag> ops = cmsTagService.loadCmsTagById(id);
		return ajaxQuery("cmsTag",ops);
    }
	
	@RequiresPermissions(value="cmsTag:updateCmsTag",desc="标签更新")
    @RequestMapping(value="/updateCmsTag", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsTag(CmsTag cmsTag){
		cmsTagService.updateCmsTag(cmsTag);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTag:deletCmsTag",desc="标签删除")
    @RequestMapping(value="/deleteCmsTag", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsTag(Long id){
		cmsTagService.deleteCmsTag(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}